#-------------------------------------------------------------------------------
# Name:        os_species
# Purpose:      isolate os-specific code
#
# Author:      Joris Bollen
#
# Created:     19-11-2010
# Copyright:   (c) Jobo 2010
# Licence:     <LGPL>
#-------------------------------------------------------------------------------
#!/usr/bin/env python

import sys
import os
import platform

operatingsyst = ''

def setCurOperatingSystem():
    global operatingsyst
    print str(sys.platform)
    if sys.platform.startswith('win'):
        operatingsyst = 'windows'
    elif sys.platform.startswith('darwin'):
        operatingsyst = 'mac'
    else:
        operatingsyst = 'linux'

def runFileAssociatedApp(filepathst):
    if operatingsyst == 'windows':
        os.startfile(filepathst)
    elif operatingsyst == 'linux':
        os.system("xdg-open '%s'" % filepathst)
    elif operatingsyst == 'mac':
        pass


def getLineSeparator(separatortypest):
    print separatortypest
    print operatingsyst
    if separatortypest == 'sep-current-os':
        print 'inside'
        if operatingsyst == 'windows':
            return '\r\n'
        elif operatingsyst == 'linux':
            print 'linux n'
            return '\n'
        elif operatingsyst == 'mac':
            pass
#        sepst = os.linesep
#        return  sepst
    elif separatortypest == 'sep-windows':
        return '\r\n'
    elif separatortypest == 'sep-linux-or-newmac':
        return '\n'
    elif separatortypest == 'sep-oldmac':
        return '\r'


def getObName(objecttypest):
    '''
    UNIT INFO
    objecttypest is user or computer
    '''
    
    if operatingsyst == 'windows':
        if objecttypest == 'user':
            return os.getenv('USERNAME')
        elif objecttypest == 'computer':
            return os.getenv('COMPUTERNAME')
    elif operatingsyst == 'linux':
        if objecttypest == 'user':
            return os.getenv('USER')
        elif objecttypest == 'computer':
            return platform.node()
    elif operatingsyst == 'mac':
        pass


if __name__ == '__main__':
    setCurOperatingSystem()
#    runFileAssociatedApp('http:/www.nu.nl')
    sepst = getLineSeparator('sep-current-os')
    print len(sepst)
    print 'klaar'
    
